home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / sframework / plugins / FileExplorer.vbs < prev    next >
Encoding:
Text File  |  2004-09-09  |  3.3 KB  |  117 lines

  1. 'FMA Script Framework Plugin
  2. 'FileExplorer
  3. 'Lets you explore your local drives and execute files
  4. 'You can even abuse it as a file launcher list by setting the FileExplorerRoot
  5. 'setting to a folder containing *.lnk files.
  6.  
  7. 'TODO:
  8. '-nothing atm
  9.  
  10. Class FileExplorer
  11.     
  12.     Private m_Self
  13.     Private mainMenu
  14.     
  15.     'Some info about the plugin
  16.     Public Property Get SHOWABLE 'Do I have a menu?
  17.         SHOWABLE    = True
  18.     End Property
  19.     Public Property Get TITLE 'What's my name?
  20.         TITLE       = "FileExplorer"
  21.     End Property
  22.     Public Property Get DESCRIPTION 'What's my purpose?
  23.         DESCRIPTION = "Lets you explore your local drives and execute files"
  24.     End Property
  25.     Public Property Get AUTHOR 'Who created me?
  26.         AUTHOR      = "streawkceur"
  27.     End Property
  28.     Public Property Get URL 'Were can I be found? Where can you get more information?
  29.         URL = "http://fma.xinium.com/"
  30.     End Property
  31.     
  32.     'Who am I?
  33.     Public Property Let Self (s)
  34.         m_Self = s
  35.     End Property
  36.     Public Property Get Self
  37.         Self = m_Self
  38.     End Property
  39.     
  40.     'Display me. Eventually put a menu on the screen
  41.     Sub Show()
  42.         If IsEmpty(Settings(Me, "Root")) Or Settings(Me, "Root") = "" Or Not Fso.FolderExists(Settings(Me, "Root")) Then Settings(Me, "Root") = "/"
  43.         ShowDir Settings(Me, "Root"), 0
  44.     End Sub
  45.     
  46.     Sub ShowDir( dir, refresh )
  47.         Dim tempList, bi
  48.         Set tempList = New LinkedList
  49.         bi = tempList.BackInserter
  50.         If refresh = 0 Then Set mainMenu = New ManagedMenu 'Only reinit the menu when not refreshing
  51.         bi.Item = Array("-> Refresh", Self & ".ShowDir """ & dir & """, 1")
  52.         If dir = "/" Then 'show drives
  53.             
  54.             Dim drv, drives,s
  55.             Set drives = FSO.Drives
  56.             For Each drv In Drives
  57.                 If drv.IsReady Then
  58.                     bi.Item = Array(">" & drv.RootFolder, Self & ".ShowDir """ & drv.RootFolder & """, 0")
  59.                 Else
  60.                     bi.Item = Array(drv.Path, "am.Update")
  61.                 End If
  62.             Next
  63.             mainMenu.Title = "Drives"
  64.             
  65.         Else 'show dir content
  66.             
  67.             If Fso.FolderExists(dir) Then
  68.                 Dim folder, subFolders, subFolder,  files, file, llFolders, llFiles, it
  69.                 Set folder     = Fso.GetFolder(dir)
  70.                 Set subFolders = folder.SubFolders
  71.                 Set files      = folder.Files
  72.                 
  73.                 Set llFolders = New LinkedList
  74.                 For Each subFolder In subFolders
  75.                     llFolders.AddBack subFolder.Path
  76.                 Next
  77.                 QuickSorter.SortLL llFolders
  78.                 it = llFolders.Begin
  79.                 Do Until it.Object Is llFolders.Last.Object
  80.                     Dim tmpFolder
  81.                     Set tmpFolder = Fso.GetFolder(it.Item)
  82.                     bi.Item = Array(">" & tmpFolder.Name, Self & ".ShowDir """ & tmpFolder.Path & """, 0")
  83.                     it.iterate()
  84.                 Loop
  85.                 
  86.                 Set llFiles = New LinkedList
  87.                 For Each file in files
  88.                     llFiles.AddBack file.Path
  89.                 Next
  90.                 QuickSorter.SortLL llFiles
  91.                 it = llFiles.Begin
  92.                 Do Until it.Object Is llFiles.Last.Object
  93.                     Dim tmpFile
  94.                     Set tmpFile = Fso.GetFile(it.Item)
  95.                     bi.Item = Array(tmpFile.Name, Self & ".Exec """ & tmpFile.Path & """")
  96.                     it.iterate()
  97.                 Loop
  98.                 mainMenu.Title = dir
  99.             Else
  100.                 mainMenu.Title = "(error)"
  101.                 Debug.ErrorMsg Self & ": Folder " & dir & "doesn't exist!"
  102.             End If
  103.             
  104.         End If
  105.         mainMenu.SetList tempList
  106.         mainMenu.ShowMenu
  107.     End Sub
  108.     
  109.     Sub Exec( file )
  110.         Debug.DebugMsg "Running: " & file
  111.         Shell.Run "RunDLL32.EXE shell32.dll,ShellExec_RunDLL """ & file & """"
  112.         am.Update
  113.     End Sub
  114.  
  115. End Class
  116.  
  117.